package com.xu.controller;

import com.xu.utils.RedisOperator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author anan
 * @create 2021-12-24 20:59
 */
@ApiIgnore //可以在swagger2显示界面中不显示该类
@RestController
@RequestMapping("redis")
public class RedisController {

/*    @Autowired
    private RedisTemplate redisTemplate;*/

    @Autowired
    private RedisOperator redisOperator;



    @GetMapping("/set")
    public Object set(String key, String value){
        redisOperator.set(key, value);
        return "ok";
    }

    @GetMapping("/get")
    public String get(String key){
        return redisOperator.get(key);
    }

    @GetMapping("/delete")
    public Object delete(String key){
        redisOperator.del(key);
        return "ok";
    }
}
